﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BG.Web.Admin.Night.Default" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <script type="text/javascript" src="../Kwan.Base.js"></script>
    <script type="text/javascript" src="Kwan.Night.js"></script>
    <form id="Form2" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="Night" />

        <ext:Store runat="server" ID="ConsumeDS">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="EntityID" />
						<ext:RecordField Name="CreatedDate" />
						<ext:RecordField Name="Item" />
						<ext:RecordField Name="Nett" />
						<ext:RecordField Name="OrderID" />
						<ext:RecordField Name="Price" />
						<ext:RecordField Name="ProductID" />
						<ext:RecordField Name="Status" />
						<ext:RecordField Name="Total" />
						<ext:RecordField Name="Type" />
						<ext:RecordField Name="UserID" />   
                        
						<ext:RecordField Name="RoomNO" />
						<ext:RecordField Name="UserName" />
						<ext:RecordField Name="CheckInDate" />
                        <ext:RecordField Name="Receivable" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>

        <ext:Store ID="Store1" runat="server" OnRefreshData="RefreshDS" RemoteSort="True">
            <Proxy>
                <ext:PageProxy />
            </Proxy>
            <Reader>
                <ext:JsonReader IDProperty="EntityID">
                    <Fields>
                        <ext:RecordField Name="EntityID" />
						<ext:RecordField Name="CardNO" />
						<ext:RecordField Name="CheckInDate" />
						<ext:RecordField Name="CheckInPrice" />
						<ext:RecordField Name="CheckInRoomPrice" />
						<ext:RecordField Name="CheckInType" />
						<ext:RecordField Name="CustomerID" />
                        <ext:RecordField Name="CreatedDate" />
						<ext:RecordField Name="Days" />
						<ext:RecordField Name="Deposit" />
						<ext:RecordField Name="DisCount" />
						<ext:RecordField Name="FinalRoomPrice" />
						<ext:RecordField Name="Memo" />
						<ext:RecordField Name="Pid" />
						<ext:RecordField Name="RoomID" />
						<ext:RecordField Name="Status" /> 

                        <ext:RecordField Name="RoomClassName" />
                        <ext:RecordField Name="RoomNO" />
                        <ext:RecordField Name="RoomStatus" />

                        <ext:RecordField Name="BillNO" />
                        <ext:RecordField Name="CashPay" />
                        <ext:RecordField Name="Change" />
                        <ext:RecordField Name="Paid" />
                        <ext:RecordField Name="PosPay" />
                        <ext:RecordField Name="Receivable" />
                        <ext:RecordField Name="CollectDate" />
                        <ext:RecordField Name="CollectStatus" />
                        <ext:RecordField Name="CollectUser" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                <ext:Parameter Name="limit" Value="20" Mode="Raw"/>
            </AutoLoadParams>
            <SortInfo Field="Status" Direction="DESC" />
            <Listeners> 
                <LoadException Handler="Ext.MessageBox.alert('系统提示', response.responseText);" />                            
            </Listeners>
        </ext:Store>
        <ext:Viewport runat="server" Layout="Fit">
            <Items>
            <ext:Panel runat="server" Header="false" Layout="Border">
            <Items>
        <ext:GridPanel ID="GridPanel1" Region="Center" RowHeight=".5" runat="server" StoreID="Store1" AutoExpandColumn="RoomNO" Header="False" Frame="true" Height="500" ColumnLines="true">
            <ColumnModel runat="server">
			    <Columns>
                    <ext:RowNumbererColumn />
					<ext:Column Header="房间号" DataIndex="RoomNO" Width="60" />
                    <ext:Column Header="房型" DataIndex="RoomClassName" Width="80" />
                    <%--<ext:Column Header="房态" DataIndex="RoomStatus" Width="80">
                        <Renderer Fn="Kwan.prepareRoomStatus" />
                    </ext:Column>--%>
					<ext:Column Header="预住天数" DataIndex="Days" Width="60" />
                    <ext:Column Header="入住房费" DataIndex="CheckInRoomPrice" Width="60" />
					<ext:Column Header="应收金额" DataIndex="Receivable" Width="60" />
                    <ext:Column Header="实收金额" DataIndex="Paid" Width="60" />
					<ext:Column Header="已交押金" DataIndex="Deposit" Width="60" />
                    <ext:Column Header="找零" DataIndex="Change" Width="50" />
                    <ext:Column Header="现金支付" DataIndex="CashPay" Width="60" />
                    <ext:Column Header="银行卡支付" DataIndex="PosPay" Width="70" />
					<ext:Column Header="入住时间" DataIndex="CheckInDate" Width="130">
                        <Renderer Fn="Kwan.fmDT" />
                    </ext:Column>
                    <ext:Column Header="退房时间" DataIndex="CollectDate" Width="130">
                        <Renderer Fn="Kwan.fmDT" />
                    </ext:Column>
                    <ext:Column Header="账单状态" DataIndex="Status" Width="70">
                        <Renderer Fn="Kwan.prepareOrderStatus" />
                    </ext:Column>
			    </Columns>
            </ColumnModel>
            <TopBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Hidden ID="txtFilter" runat="server" AutoDataBind="true">
                            <Listeners>
                                <Change Handler="Store1.reload();" Delay="30" />
                            </Listeners>
                        </ext:Hidden>
                        <ext:TriggerField Height="40" ID="qRoomNO" runat="server" EmptyText=" 搜索房间号.." EnableKeyEvents="true">
                            <Listeners>
                                <TriggerClick Handler="Kwan.search(index);" />
                            </Listeners>
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" HideTrigger="true" Qtip="清空" />
                                <ext:FieldTrigger Icon="Search" Qtip="搜索"/>
                            </Triggers>
                        </ext:TriggerField>
                        <ext:ToolbarSeparator />
                        <ext:DateField Height="40" ID="qStartDate" Vtype="daterange" EndDateField="qEndDate" runat="server" EmptyText="开始日期" />
                        <ext:DateField Height="40" ID="qEndDate" Vtype="daterange" runat="server" EmptyText="结束日期" />
                        <ext:Button ID="qSearch" Icon="Zoom" runat="server" Text="搜索">
                            <Listeners>
                                <Click Handler="Kwan.search(1);" />
                            </Listeners>
                        </ext:Button>
                        <ext:ToolbarFill />
                        <ext:Button ID="btnEditInfo" Text="夜审" Icon="Accept" runat="server">
                            <Listeners>
                                <Click Handler="Night.EditInfo();" />
                            </Listeners>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <SelectionModel>
               <ext:RowSelectionModel runat="server">
                    <Listeners>
                        <RowSelect Handler="ConsumeGP.expand(true);ConsumeGP.doLayout();#{ConsumeDS}.reload();Night.RowCommand(record.data.EntityID);" />
                        <%--<RowDeselect Handler="ConsumeGP.collapse(true);" />--%>
                    </Listeners>
                </ext:RowSelectionModel>                
            </SelectionModel>
            <LoadMask ShowMask="true" />
            <SaveMask ShowMask="true" />
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="20">
                    <Items>
                        <ext:Label runat="server" Text="每页显示:" />
                        <ext:ToolbarSpacer runat="server" Width="10" />
                        <ext:ComboBox Editable="false" runat="server" Width="80">
                            <Items>
                                <ext:ListItem Text="10" />
                                <ext:ListItem Text="20" />
                                <ext:ListItem Text="50" />
                                <ext:ListItem Text="100" />
                            </Items>
                            <SelectedItem Value="20" />
                            <Listeners>
                                <Select Handler="#{PagingToolBar1}.pageSize = parseInt(this.getValue()); #{PagingToolBar1}.doLoad();" />
                            </Listeners>
                        </ext:ComboBox>
                    </Items>
                </ext:PagingToolbar>
            </BottomBar>
            <Listeners>
                <Command Handler="Kwan.CellCommand(this, record, command, rowIndex)" />
                <%--<RowDblClick Handler="Kwan.CellCommand(this, this.store.getAt(rowIndex), 'Edit', rowIndex)" />--%>
            </Listeners>        
        </ext:GridPanel>
            
        <ext:GridPanel ID="ConsumeGP" Region="South" runat="server" ColumnLines="true" StoreID="ConsumeDS" Title="消费清单" Frame="true" Height="350" Collapsible="true" Collapsed="true" >
            <ColumnModel runat="server">
			    <Columns>
                    <ext:Column Header="订单号" DataIndex="OrderID" Width="130" />
                    <ext:Column Header="消费单号" DataIndex="EntityID" Width="130" />
					<ext:Column Header="项目名称" DataIndex="Item" Width="80" />
					<ext:Column Header="实际单价" DataIndex="Nett" Width="80" />
					<ext:Column Header="原单价" DataIndex="Price" Width="80" />
					<ext:Column Header="总数" DataIndex="Total" Width="80" />
					<ext:Column Header="消费时间" DataIndex="CreatedDate" Width="130">
                        <Renderer Fn="Kwan.fmDT" />
                    </ext:Column>
                    <ext:Column Header="操作员" DataIndex="UserName" Width="80" />
					<%--<ext:Column Header="状态" DataIndex="Status" Width="80">
                        <Renderer Fn="Kwan.prepareCSStatus" />
                    </ext:Column>--%>
			    </Columns>
            </ColumnModel>
            <SelectionModel>
               <ext:CheckboxSelectionModel runat="server" />
            </SelectionModel>
            <LoadMask ShowMask="true" />
            <SaveMask ShowMask="true" />
        </ext:GridPanel>
            </Items>
            </ext:Panel>
            </Items>
        </ext:Viewport>
        <ext:Window ID="EditWindow" runat="server" Icon="Group" Title="夜审" Width="550" Height="200" AutoShow="false" Modal="true" Collapsible="true" Maximizable="true" Hidden="true" Layout="Fit">
            <Items>
                <ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Border="false" DeferredRender="false">
                    <Items>
                        <ext:FormPanel ID="EditForm" MonitorValid="true" runat="server" Title="基本信息" Icon="ChartOrganisation" Padding="5" Layout="Form" LabelAlign="Right" LabelWidth="80" MonitorResize="true">
                            <Items>
                                <ext:Hidden ID="txtID" runat="server" />
                        <ext:Container runat="server" Layout="Column" Height="150" AnchorHorizontal="99%">
                        <Items>
                        <ext:Container runat="server" LabelAlign="Left" Layout="Form" ColumnWidth=".5">
                        <Items>
							<ext:TextField ID="txtStartDate" ReadOnly="true" FieldLabel="开始日期" Width="150" runat="server" />
							<ext:TextField ID="txtReceivable" LabelStyle="color:red;" ReadOnly="true" FieldLabel="总金额" Width="150" runat="server" />
                            <ext:TextField ID="txtCash" LabelStyle="color:red;" ReadOnly="true" FieldLabel="应收现金" Width="150" runat="server" />
                        </Items>
                        </ext:Container>
                        <ext:Container runat="server" LabelAlign="Left" Layout="Form" ColumnWidth=".5">
                        <Items>
                            <ext:TextField ID="txtEndDate" ReadOnly="true" FieldLabel="结束日期" Width="150" runat="server" />
                            <ext:TextField ID="txtPos" LabelStyle="color:red;" ReadOnly="true" FieldLabel="应收银行卡款" Width="150" runat="server" />
                            <ext:TextField ID="txtCorrect" LabelStyle="color:red;" ReadOnly="true" FieldLabel="已冲红金额" Width="150" runat="server" />
                        </Items>
                        </ext:Container>
                        </Items>
                        </ext:Container>
                            </Items>
                            <Listeners>
                                <ClientValidation Handler="#{SaveButton}.setDisabled(!valid);" />
                            </Listeners>
                        </ext:FormPanel>
                    </Items>
                </ext:TabPanel>
            </Items>
            <Buttons>
                <ext:Button ID="SaveButton" runat="server" Text="确认" Icon="Disk">
                    <%--<DirectEvents>
                        <Click OnEvent="SaveEditWindow" Failure="Ext.MessageBox.alert('系统提示', response.statusText);">
                            <EventMask Target="CustomTarget" CustomTarget="={#{EditWindow}.body}" ShowMask="True" />
                        </Click>
                    </DirectEvents>--%>
                    <Listeners>
                        <Click Handler="#{EditWindow}.hide(null);" />
                    </Listeners>
                </ext:Button>
                <ext:Button ID="CancelButton" runat="server" Text="返回" Icon="Cancel">
                    <Listeners>
                        <Click Handler="#{EditWindow}.hide(null);" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Window>
    </form>
</body>
</html>